var usernameAgree = false;
var pwdAgree = false;



function userCheck(value) {
    var userSpan = document.getElementById("logUserSpan");
    console.log(userSpan.innerHTML)
    var username = value.value;
    var patt = /[\u4e00-\u9fa5a-zA-Z0-9]+$/
    if (username == "") {
        userSpan.innerText = "用户名不能为空"
    } else if (username.length > 20) {
        userSpan.innerText = "用户名过长"
    } else if (!patt.test(username)) {
        userSpan.innerText = "用户名格式不正确"
    } else {
        userSpan.innerText = ""
        usernameAgree = true;
    }
}


function pwdCheck(params) {

    //密码正确性判断
    var pwdSpan = document.getElementById("logpwdSpan")
    var pwd = params.value
    if (pwd == "") {
        pwdSpan.innerText = "请输入密码"
    } else if (/ +/.test(pwd)) {
        pwdSpan.innerText = "密码不能有空格"
    } else if (pwd.length > 20 || pwd.length < 6) {
        pwdSpan.innerText = "密码长度有误"
    } else {
        pwdSpan.innerText = "";
        pwdAgree = true
    }
}


function loginCheck() {
    userCheck(document.getElementById("username"))
    pwdCheck(document.getElementById("password"))
    if (usernameAgree && pwdAgree) {
        return true
    } else {
        return false
    }
}